package singleton;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: tao
 * Date: 2023-12-03
 * Time: 21:46
 */
//懒汉模式
public class SingletonLazy {
    private static Object locker = new Object();
    private volatile static SingletonLazy instance = null;
    //得到instance的方法
    public static SingletonLazy getInstance() {
        if(instance == null) {
            synchronized (locker) {
                if(instance == null) {
                    instance = new SingletonLazy();
                }
            }
        }
        return instance;
    }
    private SingletonLazy() { }
}
